package com.itboye.shop.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.shop.R;
import com.itboye.shop.bean.CitysBean;

import java.util.List;


/**
 * 市
 */
public class CityAdapter extends BaseAdapter {

    Context context;
    List<CitysBean> mCityNames;

    public CityAdapter(Context context, List<CitysBean> mCityNames){
        this.context=context;
        this.mCityNames=mCityNames;
    }
    @Override
    public int getCount() {
        return mCityNames.size();
    }

    @Override
    public Object getItem(int position) {
        return mCityNames.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder holder=null;
        if(view==null){
            holder=new ViewHolder();
            view= LayoutInflater.from(context).inflate(R.layout.city_ceshi,null);
            holder.city_name= (TextView) view.findViewById(R.id.city_name);

            view.setTag(holder);
        }else{
            holder= (ViewHolder) view.getTag();
        }
        holder.city_name.setText(mCityNames.get(position).getCityName());
        return view;
    }

    class ViewHolder{
        TextView city_name;
    }
}
